package com.entity;

import java.io.Serializable;
import javax.persistence.*;

import com.alibaba.fastjson.annotation.JSONField;

import java.util.List;


/**
 * The persistent class for the STOCK database table.
 * 
 */
@Entity
@NamedQuery(name="Stock.findAll", query="SELECT s FROM Stock s")
public class Stock implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="STOCK_STOCKID_GENERATOR", sequenceName="SEQ",initialValue=1,allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="STOCK_STOCKID_GENERATOR")
	@Column(name="STOCK_ID")
	private long stockId;

	private String name;

	//bi-directional many-to-one association to Instock
	@OneToMany(mappedBy="stock")
	@JSONField(serialize=false)
	private List<Instock> instocks;

	//bi-directional many-to-one association to Storage
	@OneToMany(mappedBy="stock")
	@JSONField(serialize=false)
	private List<Storage> storages;

	public Stock() {
	}

	public long getStockId() {
		return this.stockId;
	}

	public void setStockId(long stockId) {
		this.stockId = stockId;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Instock> getInstocks() {
		return this.instocks;
	}

	public void setInstocks(List<Instock> instocks) {
		this.instocks = instocks;
	}

	public Instock addInstock(Instock instock) {
		getInstocks().add(instock);
		instock.setStock(this);

		return instock;
	}

	public Instock removeInstock(Instock instock) {
		getInstocks().remove(instock);
		instock.setStock(null);

		return instock;
	}

	public List<Storage> getStorages() {
		return this.storages;
	}

	public void setStorages(List<Storage> storages) {
		this.storages = storages;
	}

	public Storage addStorage(Storage storage) {
		getStorages().add(storage);
		storage.setStock(this);

		return storage;
	}

	public Storage removeStorage(Storage storage) {
		getStorages().remove(storage);
		storage.setStock(null);

		return storage;
	}

}